package com.homedo.microservice.open.service.gateway.alert.gateway.service;

import org.springframework.stereotype.Service;

import com.homedo.microservice.open.service.gateway.alert.gateway.bean.po.AlertNotice;
import com.homedo.microservice.open.service.gateway.alert.gateway.bean.po.enhanced.AlertNoticeEnhanced;
import com.homedo.microservice.open.service.gateway.alert.gateway.persistence.dao.AlertNoticeDao;
import com.homedo.common.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import com.homedo.common.bean.vo.context.UserContext;
import com.homedo.common.dao.bean.po.base.BasePo;
import com.google.common.collect.Lists;
import com.homedo.common.util.Detect;
import java.util.List;

/**
 *
 * @author 作者 jgshun
 * @date   创建时间 2018年10月16日 16时44分30秒
 */
@Service
public class AlertNoticeService extends BaseService<AlertNotice> {
	@Autowired
	private AlertNoticeDao alertNoticeDao;


        @Override
        public List<AlertNoticeEnhanced> getEnhanceds(List<?> ids, UserContext userContext) {
            List<AlertNotice> alertNotices = alertNoticeDao.getListByIds(ids, AlertNotice.class);

            if (!Detect.notEmpty(alertNotices)) {
            return null;
            }

            return this.convent2Enhanceds(alertNotices);
        }


        @Override
        public List<AlertNoticeEnhanced> getEnhanceds4Active(List<?> ids, UserContext userContext) {
            List<AlertNotice> alertNotices = alertNoticeDao.getListByIdsGreaterThanMark0(ids, AlertNotice.class);

                if (!Detect.notEmpty(alertNotices)) {
                return null;
                }

            return this.convent2Enhanceds(alertNotices);
         }


                @Override
                public List<AlertNoticeEnhanced> convent2Enhanceds(List<? extends BasePo> pos) {
                    List<AlertNotice> alertNotices = (List<AlertNotice>) pos;
                        List<AlertNoticeEnhanced> alertNoticeEnhanceds = Lists.newArrayList();
                            alertNotices.forEach(e -> alertNoticeEnhanceds.add(new AlertNoticeEnhanced(e)));
                            return alertNoticeEnhanceds;
                 }


}
